#!/usr/bin/perl

# $Id: 06_filter_utils.t 163 2010-06-28 16:42:26Z dolbanavt $
# $Date: 2010-06-28 19:42:32 +0300 (Пнд, 28 Июн 2010) $
# $HeadURL: https://robosearch.googlecode.com/svn/branches/reborn/t/06_filter_utils.t $
# $LastChangedRevision$

use FindBin qw( $RealBin );
use File::Spec::Functions qw( catfile );

BEGIN {
    push @INC, catfile( $RealBin, '..', 'base_lib' );
    push @INC, catfile( $RealBin, '..', 'lib' );
}

use JIP::ToolSet;
use English qw( -no_match_vars );
use Test::More tests => 13;
use Test::Exception;

use_ok 'Filter::Utils';
require_ok 'Filter::Utils';

can_ok 'Filter::Utils', qw( decode_name decode_path resolve_content_type_for );

throws_ok { decode_name(); }
    qr{^Undefined\ssubroutine\s&main::decode_name}xms,
    'decode_name() is not exported';

throws_ok { decode_path(); }
    qr{^Undefined\ssubroutine\s&main::decode_path}xms,
    'decode_path() is not exported';

throws_ok { resolve_content_type_for(); }
    qr{^Undefined\ssubroutine\s&main::resolve_content_type_for}xms,
    'resolve_content_type_for() is not exported';

is Filter::Utils::resolve_content_type_for('filename'),
   'other',
   'resolve_content_type_for() - filename';

is Filter::Utils::resolve_content_type_for('filename.ext'),
   'other',
   'resolve_content_type_for() - filename.ext';

is Filter::Utils::resolve_content_type_for('filename.avi'),
   'video',
   'resolve_content_type_for() - filename.avi';

is Filter::Utils::resolve_content_type_for('filenameavi'),
   'other',
   'resolve_content_type_for() - filenameavi';

is Filter::Utils::decode_name('tratata'),
   'tratata',
   'decode_name() - bypass ASCII';

is Filter::Utils::decode_path('/'),
   '/',
   'decode_path() - root dir';

is Filter::Utils::decode_path('/1/2/3/4'),
   '/1/2/3/4',
   'decode_path() - bypass ASCII';
